@echo off
echo Make sure you have packed the project before running this program.
for /f "delims=" %%i in ("%cd%") do set var=%%~ni
::set /p var=Input the JarFile's package name.(should whith the suffix)
set port=8081
echo Package name is: %var%.jar , Port number is: %port%

set jarfile=JrebelBrainsLicenseServerforJava-1.0-SNAPSHOT-jar-with-dependencies.jar
set currenttime=%date:~0,4%-%date:~5,2%-%date:~8,2%_%time:~0,2%%time:~3,2%%time:~6,2%
set servicename=jrebelliceneserver

set harbor=hb.ddbq.net:666
set harboruser=jrebel
set imagename=%harbor%"/"%harboruser%"/"%servicename%
echo Please login remote harbor at the first time when you use.
#docker login %harbor%

echo stopping running %servicename% container ...
docker stop %servicename%
ping -n 3 127.0.0.1>nul
docker rm %servicename% && docker rmi %imagename%:latest
ping -n 3 127.0.0.1>nul

docker rmi %imagename%:latest
ping -n 3 127.0.0.1>nul
ping -n 3 127.0.0.1>nul

docker build --no-cache --build-arg JAR_FILE=%jarfile% -t %imagename%:latest .
ping -n 1 127.0.0.1>nul
::docker push %imagename%:latest
docker run -d --name %servicename% -p %port%:%port%  %imagename%:latest
ping -n 1 127.0.0.1>nul


::docker push %imagename%:latest  docker -H 10.120.16.95:2375